package cn.buk.tms.eotms.response;

import cn.buk.tms.eotms.entity.SettlementSheet;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * 结算单 ResponseDto
 * @author yfdai
 */
public class SettlementSheetResponseDto {

    private int id;

    /**
     * 结算单号
     */
    private String settlementNo;

    /**
     * 客户名称
     */
    private String customerName;

    /**
     * 客户编号
     */
    private String customerCode;

    /**
     * 结算单名称：方便使用者区分
     */
    private String name;

    /**
     * 该结算单客户是否已支付
     * 0-未支付
     * 1-已支付
     */
    private int payStatus;

    /**
     * 结算单金额
     */
    private double amount;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date lastUpdate;

    public static SettlementSheetResponseDto createdBy(SettlementSheet settlementSheet) {
        SettlementSheetResponseDto dto = new SettlementSheetResponseDto();
        BeanUtils.copyProperties(settlementSheet, dto);

        if (settlementSheet.getCustomer() == null) {
            dto.setCustomerName("散客");
        } else {
            dto.setCustomerName(settlementSheet.getCustomer().getVipName());
            dto.setCustomerCode(settlementSheet.getCustomer().getCustomerCode());
        }

        dto.setPayStatus(settlementSheet.getPaid());

        return dto;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getSettlementNo() {
        return settlementNo;
    }

    public void setSettlementNo(String settlementNo) {
        this.settlementNo = settlementNo;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getCustomerCode() {
        return customerCode;
    }

    public void setCustomerCode(String customerCode) {
        this.customerCode = customerCode;
    }

    public int getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(int payStatus) {
        this.payStatus = payStatus;
    }
}
